package com.ymttest.database.mapping;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import com.ymttest.database.model.CoinBizcodeConfig;
import com.ymttest.database.model.FestivalRateConfig;
import com.ymttest.database.model.LevelConfig;
import com.ymttest.database.model.PrivilegeConfig;
import com.ymttest.database.model.UserCoin;
import com.ymttest.database.model.UserCoinRecord;
import com.ymttest.database.model.UserExp;
import com.ymttest.database.model.UserExpDetail;

@SuppressWarnings("rawtypes")
public interface ExpMapper {
	int insertFestivalRateConfig(FestivalRateConfig record);
	int deleteFestivalRateConfig(Map m);
	List<PrivilegeConfig> selectprivilegeconfig();
	List<UserExp> selectuserexp(Map m);
	List<UserExpDetail>selectuserexpdetail(Map m);
	int deleteuserexp(Map m);
	int deleteuserexpdetail(Map m);
	List<LevelConfig> selectlevelconfig(Map m);
	Map selectLtExp(Map m);
	Map selectOrderPrice1();
	/**
	 * @param m userid year 用户和年份查询
	 * @return
	 */
	@Select("<script>"+
			"select * from user_coin where userid=#{userid}"+
			"<if test='year !=null '>"+
				"and year=#{year}"+
			"</if>"+
		"</script>")
	List<UserCoin> selectUserCoin(Map m);
	/**
	 * @param m
	 * @return
	 */
	@Delete("<script>"+
			"delete from user_coin where userid=#{userid}"+
			"<if test='year !=null '>"+
				"and year=#{year}"+
			"</if>"+
		"</script>")
	int deleteUserCoin(Map m);
	/**
	 * @param m userid BizCode BizNo OriginalNo
	 * @return
	 */
	@Select("<script>"+
			"select * from user_coin_record where userid=#{userid}"+
			"<if test='BizCode !=null '>"+
				"and BizCode=#{BizCode}"+
			"</if>"+
			"<if test='BizNo !=null '>"+
				"and BizNo=#{BizNo}"+
			"</if>"+
			"<if test='OriginalNo !=null '>"+
				"and OriginalNo=#{OriginalNo}"+
			"</if>"+
			"<if test='operateType ==1 '>"+
				"and totalcoin &gt; 0"+
			"</if>"+
			"<if test='operateType ==2 '>"+
				"and totalcoin &lt; 0"+
			"</if>"+
			"order by id desc"+
		"</script>")
	List<UserCoinRecord> selectUserCoinRecord(Map m);
	@Delete("<script>"+
			"delete from user_coin_record where userid=#{userid}"+
			"<if test='BizCode !=null '>"+
				"and BizCode=#{BizCode}"+
			"</if>"+
			"<if test='BizNo !=null '>"+
				"and BizNo=#{BizNo}"+
			"</if>"+
			"<if test='OriginalNo !=null '>"+
				"and OriginalNo=#{OriginalNo}"+
			"</if>"+
		"</script>")
	int deleteUserCoinRecord(Map m);
	@Insert({
        "insert into user_coin (Id, UserId, ",
        "Coin, Year, CreateTime, ",
        "LastUpdateTime)",
        "values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=INTEGER}, ",
        "#{coin,jdbcType=INTEGER}, #{year,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{lastUpdateTime,jdbcType=TIMESTAMP})"
    })
    int insertUserCoin(UserCoin record);
	
	/**
	 * key:OrderId CatalogNum
	 * @param orderCatalogNum
	 * @return
	 */
	@Insert({
        "insert into order_catalog_num (OrderId, CatalogNum,EvalStatus)",
        "values (#{OrderId,jdbcType=BIGINT}, #{CatalogNum,jdbcType=INTEGER},0)"
    })
    int insertOrderCatalogNum(Map orderCatalogNum);
	
	@Delete("delete from order_catalog_num where OrderId=#{OrderId}")
	int deleteOrderCatalogNum(Map m);
	@Select("select * from coin_bizcode_config where bizcode=#{bizcode}")
	List<CoinBizcodeConfig> selectCoinBizcodeConfig(String bizcode);
	@Select("select * from order_catalog_num where OrderId=#{OrderId}")
	List<Map>selectOrderCatalogNum(String OrderId);
}
